<div class="Item hr">
    <div class="current">自定义资料列表</div>
    <div class="fr"><a href="{:U('add')}" class="btn">添加新自定义资料</a></div>
</div>
<form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td>选择</td>
                <td>说明</td>
                <td>标识</td>
            <present name="language">
                <td>语言</td>
            </present> 
                <td>模板调用代码</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="list" id="mylang" empty="$empty">
            <tr align="center">
                <td>{:genCheckbox('id', '', $mylang['id'], false, 'id')}</td>
                <td>{$mylang.cid}</td>
                <td>{$mylang.eid}</td>
            <present name="language">
                <td>{$mylang['lang']|getLangTitle}</td>
            </present> 
                <td>&lt;mylang eid='{$mylang.eid}' /&gt</td>
                <td> <a href="{:U('edit', array('id' => $mylang['id']))}" class="icon icon-black icon-edit" title="编辑"></a> <a href="javascript:;" class="deleted icon icon-black icon-trash" data-url="{:U('delete')}" data-id="{$mylang.id}" data-title="{$mylang.cid}" title="删除"></a> </td>
            </tr>
            </volist>
        </tbody>
        
    </table>
</form>

<div class="page">
    {$page}
</div>
<div class="commonBtnArea" >
    <label><input name="" class="chooseAll" type="checkbox"> 全选</label> <label><input name="" class="unsetAll" type="checkbox"> 反选</label>
    <button class="btn" id="deleted" data-url="{:U('delete')}">删除</button>
</div>
<script type="text/javascript">
$(function(){
	clickCheckbox();
    $(".deleted").click(function(){
        var url = $(this).data("url");
        var id = $(this).data("id");
        var name = $(this).data("title");

        popup.confirm("您确定删除 <b>" + name + "</b> ？", '温馨提示',function(action){
            if(action == 'ok'){
                $.ajax({
					'url' : url,
					'dataType' : 'JSON',
					'type' : 'POST',
					'data' : {'id' : id},
					'success' : function(json){
						if (json.status) {
							popup.success(json.info, "删除成功", function(){
								if(json.url){
									window.location.href = json.url;
								}else{
									top.window.location.reload();
								}
							});
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
				});
            }
        });

        return false;
    });
	
	//批量删除
    $("#deleted").click(function(){
        var url = $(this).data("url");
		var isDeleted = false;
		var ids = [];
		$(".id").each(function(){
			if($(this).prop("checked")){
				isDeleted = true;
				ids.push($(this).val());
			}
		})
		if(isDeleted){
			popup.confirm("您确定批量删除？", '温馨提示',function(action){
				if(action == 'ok'){
					$.ajax({
						"url" : url,
						"dataType" : "JSON",
						"type" : "POST",
						"data" : {"ids" : ids, "act" : "two"},
						"success" : function(json){
						if (json.status) {
							popup.success(json.info, "删除成功", function(){
								if(json.url){
									window.location.href = json.url;
								}else{
									top.window.location.reload();
								}
							});
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
					});
				}
			});
		}
        return false;
    });
});
</script>
